package com.ftg.learn.controller;

import com.ftg.learn.service.SysRoleService;
import com.ftg.learn.util.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 布衣
 */
@RestController
@RequestMapping("/role")
public class SysRoleController {
    @Resource
    SysRoleService sysRoleService;

    @PostMapping("/save")
    public R<Integer> save(@RequestParam("rolename") String rolename) {
        return sysRoleService.save(rolename);
    }

    /**
     * 为角色分配资源
     */
    @PostMapping("/assignResource")
    public R<Boolean> assignResource(@RequestParam("roleId") Integer roleId, @RequestParam("resourceIds") List<Integer> resourceIds) {
        return sysRoleService.assignResource(roleId, resourceIds);
    }
}
